/*
 * This file (RxParamFilter.java) is protected by the GNU GPL licence (v2). 
 * Please read the license.txt attached for further informations. 
 * 
 */

package alkwarel.objects;

import artx.utils.AxRandom;

/**
 * @author Xavier Gouchet
 * 
 */
public abstract class RxParamFilter extends RxFilter {

	private int min, max;

	/** the parameter when the call is made */
	protected int param;

	/**
	 * Standard Constructor.
	 * 
	 * @param id
	 *            the object's id
	 * @param name
	 *            the object's name
	 * @param min
	 *            min parameter value
	 * @param max
	 *            max parameter value
	 */
	public RxParamFilter(int id, String name, int min, int max) {
		super(id, name);
		this.max = max;
		this.min = min;
	}

	/**
	 * @see alkwarel.objects.RxSimpleFilter#FilterPixel()
	 */
	protected abstract void FilterPixel();

	/**
	 * @see alkwarel.objects.RxFilter#Apply(alkwarel.objects.AkArtspace)
	 */
	public final boolean Apply(AkArtspace a) {
		this.param = AxRandom.RandI(this.min, this.max);
		for (int x = 0; x < a.width; x++) {
			for (int y = 0; y < a.height; y++) {
				this.RGBHSV(a.get(x, y));

				this.FilterPixel();

				this.HSVRGB();
				a.set(x, y, this.coulref);
			}
		}
		return true;
	}

}
